import argparse
from dataclasses import dataclass, field
import sys
from typing import List

def parse_args(arg_list: List[str]) -> argparse.Namespace:
    original_argv = sys.argv.copy()
    sys.argv = ["es"] + arg_list

    from vllm.utils import FlexibleArgumentParser
    from vllm.entrypoints.openai.cli_args import make_arg_parser, validate_parsed_serve_args
    parser = FlexibleArgumentParser(description="vLLM parser")
    parser = make_arg_parser(parser)
    args = parser.parse_args()
    validate_parsed_serve_args(args)

    sys.argv = original_argv

    return args


